import 'package:flutter/material.dart';
import 'package:zhrs/Model/exploremessage.dart';
import 'package:zhrs/Model/message.dart';
import 'package:zhrs/mainpage/explorebutton.dart';
import 'package:zhrs/Utils/windowsSize.dart';


class Exploreindex extends StatefulWidget
{

  Function reset;
  Exploreindex({this.index=1,this.reset})
  {
         if(this.index==1)
       {
         eploremessagelist=eploremessagemap["man"];
         exploremanmessagelist=exploremanmessagemap["man"];
         imgURL="http://106.12.180.103/smartDemo/images/head-male.png";
       }
         if(this.index==2)
       {
         eploremessagelist=eploremessagemap["woman"];
         exploremanmessagelist=exploremanmessagemap["woman"];
         imgURL="http://106.12.180.103/smartDemo/images/head-female.png";
       }
         if(this.index==3)
       {
         eploremessagelist=eploremessagemap["old"];
         exploremanmessagelist=exploremanmessagemap["old"];
         imgURL="http://106.12.180.103/smartDemo/images/head-aged.png";
       }
  }
  int index;

  List< List<exploreexperience> > eploremessagelist;
  List<double> op=[1.0,0.5,0.5,0.5];
  Explorebutton  ss;
  List< List<exploremanmessage1>> exploremanmessagelist ;
  String imgURL;
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _Exploreindex();
  }
}
class _Exploreindex extends State<Exploreindex> {
  @override
  void initState() {
    // TODO: implement initState

    super.initState();

  }

 void refreshop(int index)
 {
   for(int i=0;i<widget.op.length;i++)
     {
       if(index==i) {
         widget.op[index]=1.0;
          }
       else
         widget.op[i]=0.5;
     }
 }
  void navaicateTopage(String url)
  {
    print(alertDialog(context, url));
  }
  bool once =true;
  @override
  Widget build(BuildContext context) {
    windowsSize.mapViewWidth = MediaQuery
        .of(context)
        .size
        .width;
    windowsSize.mapViewHeight = MediaQuery
        .of(context)
        .size
        .height;

    if(once)
      {
        widget.ss=new Explorebutton(upordown: "up",exploremessage: widget.exploremanmessagelist[1],reset:widget.reset);
        once=false;
      }

    // TODO: implement build
    return SafeArea(
      child:  Scaffold(
        body:  new Container(
          child:  MediaQuery.removePadding(
              removeTop: true,
              context: context,
              child: Container(
                color: Colors.blue,
                height:windowsSize.mapViewHeight ,
                child: ListView(
                  children: <Widget>[
                    Column(
                      children: <Widget>[
                        Row(
                          children: <Widget>[
                            Container(
                              padding:EdgeInsets.only(left:30),
                              height:windowsSize.mapViewHeight*0.05 ,
                              width: windowsSize.mapViewWidth*0.9,
                              child: Text("发现",textAlign: TextAlign.center,style: TextStyle(fontSize:20 ,color: Colors.white,decoration: TextDecoration.none),),
                            ),
                            Container(
                              height:windowsSize.mapViewHeight*0.05 ,
                              width: windowsSize.mapViewWidth*0.1,
                              child:Icon(Icons.format_list_bulleted,
                                //size: windowsSize.mapViewHeight * 0.05,
                                color: Colors.white,) ,
                            ),
                          ],
                        ),
                        Center(
                            child: Stack(

                              children: <Widget>[

                                Padding(
                                //  color:Colors.red,
                                //  width: windowsSize.mapViewWidth,
                                 padding: EdgeInsets.only(left:windowsSize.mapViewWidth*0.07,top: windowsSize.mapViewHeight*0.18),
                                  child:
                                  Center(

                                    child:  new ClipRRect(
                                      borderRadius: const BorderRadius.all(const Radius.circular(360.0)),
                                      child:Container(
                                       // color: Colors.green,
                                        width: windowsSize.mapViewWidth*0.9,
                                        child: Stack(
                                          children: <Widget>[
                                            Padding(
                                                padding: EdgeInsets.only(left: 5.5,top: 1.5 ),
                                                child: new GestureDetector(
                                                  onTap: ()
                                                  {
                                                    setState(() {
                                                      refreshop(0);
                                                      widget.ss=new Explorebutton(upordown:"up",exploremessage:  widget.exploremanmessagelist[1],reset: widget.reset,);
                                                      //Navigator.push(context, new MaterialPageRoute(
                                                      //builder :(context)=>new Page2(),
                                                      //));
                                                    });
                                                  },
                                                  child: Container(

                                                    // color:Colors.redAccent,
                                                    width: 195,
                                                    height:135,

                                                    child:Stack(
                                                      children: <Widget>[
                                                        new Opacity(
                                                          opacity: widget.op[0],//不透明度
                                                          child: new Image.network(//加载网络图片
                                                            'http://106.12.180.103/smartDemo/images/circle-4.png',
                                                            // repeat: ImageRepeat.noRepeat,//图片重复方式
                                                            fit: BoxFit.fill,
                                                          ),
                                                        ),

                                                        Padding(
                                                          padding: EdgeInsets.only(left: 15,top: 75),
                                                          child:Icon(Icons.device_hub,color: Colors.white,) ,
                                                        ),
                                                        Padding(
                                                          padding: EdgeInsets.only(left: 50,top: 40),
                                                          child: Container(
                                                            child: Column(
                                                              children:widget.eploremessagelist[0].map((exploreexperience){
                                                                return  Container(
                                                                  width: 80,
                                                                  child:  Text(exploreexperience.description1,style: TextStyle(color: Colors.white),),
                                                                );
                                                              }).toList(),
                                                            ),
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding: EdgeInsets.only(left: 135,top: 15),
                                                          child: Container(
                                                            // color: Colors.redAccent,
                                                            child: Column(
                                                              children: <Widget>[
                                                                Container(
                                                                  width: 40,
                                                                  child: Text("基本信息",style: TextStyle(fontSize: 18,color: Colors.white),),
                                                                )
                                                              ],
                                                            ),
                                                          ),
                                                        ),
                                                      ],
                                                    ),
                                                  ) ,
                                                )
                                            ),
                                            Padding(
                                                padding: EdgeInsets.only(left: 173,top: 4 ),
                                                child: new GestureDetector(
                                                    onTap: ()
                                                    {
                                                      setState(() {
                                                        refreshop(1);
                                                        widget.ss=new Explorebutton(upordown:"up",exploremessage:  widget.exploremanmessagelist[0],reset: widget.reset,);
                                                        //Navigator.push(context, new MaterialPageRoute(
                                                        //  builder :(context)=>new Page2(),
                                                        // ));
                                                      });
                                                    },
                                                    child:Stack
                                                      (
                                                      children: <Widget>[

                                                        Container(
                                                          // color:Colors.redAccent,
                                                          width: 135,
                                                          height:195,
                                                          child: new Opacity(
                                                            opacity: widget.op[1],//不透明度
                                                            child: new Image.network(//加载网络图片
                                                              'http://106.12.180.103/smartDemo/images/circle-3.png',
                                                              // repeat: ImageRepeat.noRepeat,//图片重复方式
                                                              fit: BoxFit.fill,
                                                            ),
                                                          ),
                                                        ) ,

                                                        Padding(
                                                          padding: EdgeInsets.only(left: 32,top: 60),
                                                          child: Container(
                                                            //  color: Colors.redAccent,

                                                            // color: Colors.redAccent,
                                                            child: Column(
                                                              children: widget.eploremessagelist[1].map((exploreexperience)
                                                              {
                                                                return   Container(
                                                                  //     color: Colors.redAccent,
                                                                  width: 100,
                                                                  child: Text(exploreexperience.description1,style: TextStyle(color: Colors.white),),
                                                                );
                                                              }).toList(),
                                                            ),
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding: EdgeInsets.only(left: 70,top: 130),
                                                          child: Container(
                                                            // color: Colors.redAccent,
                                                            child: Column(
                                                              children: <Widget>[
                                                                Container(
                                                                  width: 40,
                                                                  child: Text("就业经历",style: TextStyle(fontSize: 18,color: Colors.white),),
                                                                )
                                                              ],
                                                            ),
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding: EdgeInsets.only(left: 35,top: 15),
                                                          child:Icon(Icons.next_week,color: Colors.white,) ,
                                                        ),
                                                      ],
                                                    )

                                                )

                                            ),
                                            Padding(
                                              padding: EdgeInsets.only(left: 109,top: 172 ),
                                              child: Container(
                                                // color:Colors.redAccent,
                                                width: 195,
                                                height:135,
                                                child:new GestureDetector(
                                                    onTap: ()
                                                    {
                                                      setState(() {
                                                        refreshop(2);

                                                        widget.ss=new Explorebutton(upordown:"down",exploremessage: widget. exploremanmessagelist[2],reset: widget.reset,);

                                                        //Navigator.push(context, new MaterialPageRoute(
                                                        //  builder :(context)=>new Page2(),
                                                        // ));
                                                      });
                                                    },
                                                    child: Stack(
                                                      children: <Widget>[
                                                        Container(
                                                          // color:Colors.redAccent,
                                                          width: 195,
                                                          height:135,
                                                          child: new Opacity(
                                                            opacity: widget.op[2],//不透明度
                                                            child: new Image.network(//加载网络图片
                                                              'http://106.12.180.103/smartDemo/images/circle-2.png',
                                                              // repeat: ImageRepeat.noRepeat,//图片重复方式
                                                              fit: BoxFit.fill,
                                                            ),
                                                          ),
                                                        ) ,

                                                        Padding(
                                                          padding: EdgeInsets.only(left: 55,top: 45),
                                                          child: Container(
                                                            //  color: Colors.redAccent,

                                                            // color: Colors.redAccent,
                                                            child: Column(
                                                              children:
                                                              widget.eploremessagelist[2].map((exploreexperience)
                                                              {
                                                                return   Container(
                                                                  //     color: Colors.redAccent,
                                                                  width: 90,
                                                                  child: Text(exploreexperience.description1,style: TextStyle(color: Colors.white),),
                                                                );
                                                              }).toList(),
                                                            ),
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding: EdgeInsets.only(left: 10,top: 65),
                                                          child: Container(
                                                            // color: Colors.redAccent,
                                                            width: 40,
                                                            child: Column(

                                                              children: <Widget>[
                                                                Container(

                                                                  child: Text("健康保障",style: TextStyle(fontSize: 18,color: Colors.white),),
                                                                )
                                                              ],
                                                            ),
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding: EdgeInsets.only(left: 155,top: 35),
                                                          child:Icon(Icons.favorite_border,color: Colors.white,) ,
                                                        ),
                                                      ],
                                                    )

                                                ),
                                              ) ,
                                            ),
                                            Padding(
                                              padding: EdgeInsets.only(left:1,top: 107 ),
                                              child: Container(
                                                // color:Colors.redAccent,
                                                width: 135,
                                                height:195,
                                                child:new GestureDetector(
                                                    onTap: ()
                                                    {
                                                      setState(() {
                                                        refreshop(3);
                                                        widget.ss=new Explorebutton(upordown:"down",exploremessage: widget.exploremanmessagelist[3],reset: widget.reset,);

                                                        //Navigator.push(context, new MaterialPageRoute(
                                                        //  builder :(context)=>new Page2(),
                                                        // ));
                                                      });
                                                    },
                                                    child: Stack(
                                                      children: <Widget>[
                                                        Container(
                                                          // color:Colors.redAccent,
                                                          width: 135,
                                                          height:195,
                                                          child: new Opacity(
                                                            opacity: widget.op[3],//不透明度
                                                            child: new Image.network(//加载网络图片
                                                              'http://106.12.180.103/smartDemo/images/circle-1.png',
                                                              fit: BoxFit.fill,
                                                            ),
                                                          ),
                                                        ) ,

                                                        Padding(
                                                          padding: EdgeInsets.only(left: 22,top: 70),
                                                          child: Container(
                                                            child: Column(
                                                              children: widget.eploremessagelist[3].map((exploreexperience)
                                                              {
                                                                return   Container(
                                                                  //color: Colors.redAccent,
                                                                  width: 82,
                                                                  child: Text(exploreexperience.description1,style: TextStyle(color: Colors.white),),
                                                                );
                                                              }).toList(),
                                                            ),
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding: EdgeInsets.only(left: 25,top: 10),
                                                          child: Container(
                                                            // color: Colors.redAccent,
                                                            child: Column(
                                                              children: <Widget>[
                                                                Container(
                                                                  width: 40,
                                                                  child: Text("智能评测",style: TextStyle(fontSize: 18,color: Colors.white),),
                                                                )
                                                              ],
                                                            ),
                                                          ),
                                                        ),
                                                        Padding(
                                                          padding: EdgeInsets.only(left: 80,top: 155),
                                                          child:Icon(Icons.pie_chart_outlined,color: Colors.white,) ,
                                                        ),
                                                      ],
                                                    )
                                                ),
                                              ) ,
                                            ),
                                            Padding(
                                              padding: EdgeInsets.only(left:98,top: 96 ),
                                              child:   Container(
                                                decoration: BoxDecoration(border: Border.all(width:7, color: Colors.white30),
                                                    shape: BoxShape.rectangle,
                                                    borderRadius:
                                                    const BorderRadius.all(const Radius.circular(360.0))),
                                                child: new ClipRRect(
                                                  borderRadius: const BorderRadius.all(const Radius.circular(360.0)),
                                                  child:Container(
                                                    height:100,
                                                    width:100,
                                                    child:  new Image.network(//加载网络图片
                                                      widget.imgURL,
                                                      repeat: ImageRepeat.noRepeat,//图片重复方式
                                                      // fit: BoxFit.fill,
                                                    ),
                                                  ),
                                                ),
                                              ),
                                            ),
                                          ],
                                        ),
                                      ) ,
                                    ),
                                  )

                                ),
                                widget.ss,
                              ],
                            )
                        ),

                        Center(

                          child:
                          Padding(
                            padding:   EdgeInsets.only(top: 20 ),
                            child:  new ClipRRect(
                                borderRadius: const BorderRadius.all(const Radius.circular(60.0)),
                                child:
                                new GestureDetector(
                                  onTap: ()
                                  {
                                    setState(() {


                                      showCupertinoDialogs(context, "建设中,敬请期待...");

                                    });
                                  },
                                  child:   Container(

                                    color: Colors.white30,
                                    width: 80,
                                    height: 80,
                                    child:Center(
                                      child:
                                        Column(
                                          mainAxisAlignment: MainAxisAlignment.center,
                                          children: <Widget>[
                                            Icon(Icons.mic_none,color: Colors.white,size: 30,),
                                          Text("语音搜索",textAlign: TextAlign.center,style: TextStyle(color: Colors.white,decoration: TextDecoration.none,fontSize: 13)),
                                          ],


                                    ),
                                    ) ,
                                  ),)
                            ),
                          )




                        ),

                        Container(
                         height: 50,
                        )
                      ],
                    )
                  ],
                ),
              )
          ),
        ),
      ),
      );


  }
}